package com.danger.Presenter;

import android.content.Context;

import com.danger.Model.action.ObjectInfoModel;
import com.danger.Model.action.ObjectInfoModelImpl;
import com.danger.Model.bean.ObjectInfo;
import com.danger.Model.listener.OnGetListener;
import com.danger.View.ObjectInfoView;

import java.util.List;

/**
 * Created by danger on 2016/3/29.
 */
public class LostPresenterImpl implements LostPresenter {

    private Context context;
    private ObjectInfoModel objectInfoModel;
    private ObjectInfoView objectInfoView;

    public LostPresenterImpl(Context context, ObjectInfoView myView) {
        this.context = context;
        this.objectInfoView = myView;
        objectInfoModel = new ObjectInfoModelImpl(context);
    }

    @Override
    public void queryLost() {
        objectInfoView.showDialog();
        objectInfoModel.getLostObjectInfo(new OnGetListener() {
            @Override
            public void onSuccess(List<ObjectInfo> list) {
                objectInfoView.hideDialog();
                objectInfoView.showSuccess(list);
            }

            @Override
            public void onError(String error) {
                objectInfoView.hideDialog();
                objectInfoView.showError(error);
            }
        });
    }

    @Override
    public void refersh() {
        objectInfoModel.getLostObjectInfo(new OnGetListener() {
            @Override
            public void onSuccess(List<ObjectInfo> list) {
                objectInfoView.showRefershSuccess(list);
            }

            @Override
            public void onError(String error) {
                objectInfoView.showRefreshError(error);
            }
        });
    }
}
